﻿CREATE PROCEDURE admin.s_State_ReCreateEnums AS
DECLARE @SQL nvarchar(max) SET @SQL = ''
SELECT @SQL = @SQL+'
EXEC ('''+
admin.MakeEnumObjectNameSQL(
	admin.MakeStateEnumObjectName(ID),
	't_State',ID,
	OBJECT_ID(admin.MakeStateEnumObjectName(ID))
)+'
'')
'
FROM t_State WHERE ParentID > 0 
PRINT @SQL
--EXEC(@SQL)

SET @SQL = ''
SELECT @SQL = @SQL+'
EXEC (''
'+
admin.MakeEnumObjectNameSQL(
	admin.MakeStateParamEnumObjectName(ID),
	'ts_StateParameter',ID,
	OBJECT_ID(admin.MakeStateParamEnumObjectName(ID))
)+'
'')
'
FROM ts_StateParameter-- WHERE ParentID > 0 
PRINT @SQL
--EXEC(@SQL)
--SELECT o.name FROM syscomments c INNER JOIN sys.objects o ON c.id = o.object_id
--WHERE c.text like '%'+@ObjectName+'%'


--SELECT o.name FROM syscomments c INNER JOIN sys.objects o ON c.id = o.object_id
--WHERE c.text like '%'+@ObjectName+'%'

